﻿define([
    'Xjs/core/util',
    'Xjs/ui/Container',
    'Xjs/ui/table/TableBodyCell' // Include the cell by default
],
function (util, Container) {
    'use strict';

    var type = 'tableBodyRow',
    TableBodyRow = Xjs.getType(type);

    if (TableBodyRow) { // It has been already loaded
        return TableBodyRow;
    }

    TableBodyRow = util.define({
        base: Container,
        construct: function (conf, parent) {
            TableBodyRow.base.constructor.call(this, conf, parent); // Call the base constructor
        },
        tag: 'tr',
        type: type,
        defaultChildType: 'tableBodyCell', // Set the default type of the child to be created
        childrenProperty: 'cells',

        createCell: function (conf) {
            var cell = Xjs.create('tableBodyCell', conf, this);
            this.addChild(cell);
            return cell;
        },

        getCell: function (i) {
            return this.children[i];
        }
    });

    Xjs.registerType(TableBodyRow);

    return TableBodyRow;
});